#include "objectset.h"

namespace losor
{
	list<object*> objectset::operator[]( string key )
	{
		list<object*> obj;
		objectset::iterator i;
		i = m_object.find( key );
		while( i->first == key )
		{
			obj.push_back( i->second );
			++i;
		}
		return obj;
	}
	
	void objectset::insert( string key, object *val )
	{
		m_object.insert( pair<string,object*>( key, val ) );
	}
	
	void objectset::erase( object *val )
	{
		objectset::iterator i;
		// for this case, objectset depends on object
		i = m_object.find( val->caption() );
		while( i->first == val->caption() )
		{
			if( i->second == val )
			{
				m_object.earse( i );
				--i;
			}
			++i;
		}
	}
	
	void objectset::erase( string key )
	{
		objectset::iterator i;
		i = m_object.find( key );
		while( i->first == key )
		{
			if( i->second == key )
			{
				m_object.earse( i );
				--i;
			}
			++i;
		}
	}
	
	objectset::iterator objectset::begin()
	{
		return m_object.begin();
	}
	
	objectset::iterator objectset::end()
	{
		return m_object.end();
	}
	
}

